package Threadtest;

public class demo2 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            System.out.println(Thread.currentThread().getName()+"开始干活...");
        },"zhangsan");
        Thread t2 = new Thread(() -> {
            for (int i = 0; i <5 ; i++) {
                try {
                    t1.sleep(1000);
                    System.out.println(t1.getName()+"停下来...");
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }

        });
        Thread t3 = new Thread(() -> {
             Object locker = new Thread();
            synchronized (locker)
            {
                try {
                    t1.join();
                } catch (InterruptedException e) {
                    System.out.println(t1.getName()+"经过了可重入锁阻塞等待...");
                    throw new RuntimeException(e);
                }
            }
        });

        t1.start();
        t2.start();
        t3.start();



    }
}
